<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2022-04-25
  Time: 11:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>学生信息管理</title>

    <script>
        window.onload=function (){
            let msg = "<%=session.getAttribute("msg")%>";
            if(msg != "null"){
                alert(msg);
            }
            <c:remove var="msg" scope="session"></c:remove>
        }
    </script>
    <style>
        #app{
            width: 800px;
            margin: 0px auto;
        }
        .evenLine{
            background-color: beige;
        }
        .oddLine{
            background-color: aquamarine;
        }
        th{
            background-color: cornflowerblue;
            color: white;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div id="app">
        <h3>学生信息管理系统</h3>
        <span style="float: right">
        <a href="reg.html">添加</a>
    </span>
        <table width="100%">
            <tr>
                <th>学号</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>性别</th>
                <th>地址</th>
                <th>电话</th>
                <th>操作</th>
            </tr>

                <c:forEach items="${list}" var="stu" varStatus="vs">
                    <tr <c:if test="${vs.index % 2== 0}">class="evenLine"</c:if> <c:if test="${vs.index % 2!= 0}">class="oddLine"</c:if>>
                        <td>${stu.id}</td>
                        <td>${stu.name}</td>
                        <td>${stu.age}</td>
                        <td>${stu.sex}</td>
                        <td>${stu.address}</td>
                        <td>${stu.telephone}</td>
                        <td>
                            <a href="toUpdate?id=${stu.id}">修改</a> &nbsp;&nbsp; <a href="delete?id=${stu.id}">删除</a>
                        </td>
                    </tr>
                </c:forEach>
        </table>
    </div>

</body>
</html>
